package cn.jly.spring.annotation.ioc;

import cn.jly.spring.annotation.ioc.bean.Person;
import cn.jly.spring.annotation.ioc.config.MainConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

/**
 * @author lanyangji
 * @description 基于注解的主类
 * @date 2020/11/12 上午 8:40
 */
public class MainAnnoApp {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext =
                new AnnotationConfigApplicationContext(MainConfig.class);

        final Person person = applicationContext.getBean(Person.class);
        System.out.println("person = " + person);

        final String[] names = applicationContext.getBeanNamesForType(Person.class);
        System.out.println(Arrays.toString(names));

        applicationContext.close();
    }
}
